﻿<UserControl x:Class="EpiNEXT.WPF.View.Pages.DataEntry"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:view="clr-namespace:EpiNEXT.WPF.View"
             xmlns:local="clr-namespace:EpiNEXT.WPF.View.Pages"
             xmlns:controls="clr-namespace:EpiNEXT.WPF;assembly=EpiNEXT.WPF"
             xmlns:pages="clr-namespace:EpiNEXT.WPF.View.Pages"
             xmlns:content="clr-namespace:EpiNEXT.WPF.View.Content"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             mc:Ignorable="d" 
             d:DesignHeight="1040" d:DesignWidth="780">
    <UserControl.InputBindings>
        <KeyBinding Command="{Binding SaveRecordAsyncCommand}"
              Gesture="CTRL+S" />
        <KeyBinding Command="{Binding AddRecordCommand}"
              Gesture="CTRL+N" />
        <KeyBinding Command="{Binding ToggleTabIndicesCommand}"
              Gesture="CTRL+T" />
        <KeyBinding Command="{Binding TogglePrintPreviewCommand}"
              Gesture="CTRL+P" />
        <KeyBinding Command="{Binding ToggleSearchCommand}"
              Gesture="CTRL+F" />
    </UserControl.InputBindings>
    <UserControl.Resources>
        <!--<ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/ModernUI.Light.xaml"/>
                <ResourceDictionary>-->
                    <Style x:Key="SliderIncrement" TargetType="{x:Type RepeatButton}">
                        <Setter Property="SnapsToDevicePixels" Value="true"/>
                        <Setter Property="OverridesDefaultStyle" Value="true"/>
                        <Setter Property="IsTabStop" Value="false"/>
                        <Setter Property="Focusable" Value="false"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type RepeatButton}">
                                    <!--<Canvas HorizontalAlignment="Right">
                            <Canvas Margin="6,0,0,0">
                                <Path Stretch="Fill" Height="14" Width="14" Fill="{StaticResource WindowBackgroundBrush}" Data="F1 M 35,19L 41,19L 41,35L 57,35L 57,41L 41,41L 41,57L 35,57L 35,41L 19,41L 19,35L 35,35L 35,19 Z "/>
                            </Canvas>
                        </Canvas>-->
                                    <Grid Background="Transparent" HorizontalAlignment="Right" Margin="0, 0, 0, 0">
                            <Rectangle Fill="{StaticResource DarkTextBrush}"
                                       Width="8" Height="2" HorizontalAlignment="Center" VerticalAlignment="Center" />
                            <Rectangle Fill="{StaticResource DarkTextBrush}"
                                       Width="2" Height="8" HorizontalAlignment="Center" VerticalAlignment="Center" />
                                        <!--<Canvas Margin="-10,6,0,0">
                                <Path Stretch="Fill" Height="2" Width="14" Fill="{StaticResource WindowBackgroundBrush}" Data="F1 M 19,38L 57,38L 57,44L 19,44L 19,38 Z "/>
                            </Canvas>-->
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>

                    <Style x:Key="ThumbBall" TargetType="{x:Type Thumb}">
                        <Setter Property="SnapsToDevicePixels" Value="True"/>
                        <Setter Property="OverridesDefaultStyle" Value="True"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate>
                        <Rectangle Fill="{StaticResource DarkTextBrush}"
                                   Height="14"
                                   Width="5"
                                   VerticalAlignment="Center"
                                   x:Name="TrackBall"
                                   />

                                    <!--<Path StrokeThickness="0.250000" Stroke="#FFA2A2A2" StrokeMiterLimit="1.000000" 
                              Data="F1 M 0,3.455078 C 0,1.615723 1.490234,0.125000 3.330078,0.125000 C 5.168945,0.125000 6.659179,1.615723 6.659179,3.455078 C 6.659179,5.292969 5.168945,6.784180 3.330078,6.784180 C 1.490234,6.784180 0,5.292969 0,3.455078 Z" x:Name="TrackBall" Opacity="1" Fill="{StaticResource WindowBackgroundBrush}" />-->

                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter TargetName="TrackBall" Property="Fill" Value="White"/>
                                        </Trigger>
                                        <Trigger Property="IsEnabled" Value="False">
                                            <Setter TargetName="TrackBall" Property="Opacity" Value="0.5"/>
                                        </Trigger>
                                    </ControlTemplate.Triggers>

                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>


                    <Style x:Key="SliderDecrement" TargetType="{x:Type RepeatButton}">
                        <Setter Property="SnapsToDevicePixels" Value="true"/>
                        <Setter Property="OverridesDefaultStyle" Value="true"/>
                        <Setter Property="IsTabStop" Value="false"/>
                        <Setter Property="Focusable" Value="false"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type RepeatButton}">
                                    <Grid HorizontalAlignment="Left" Background="Transparent" Margin="0, 0, 15, 0">
                            <Rectangle Fill="{StaticResource DarkTextBrush}"
                                       Width="6" Height="2" HorizontalAlignment="Center" VerticalAlignment="Center" />
                                        <!--<Canvas Margin="-10,6,0,0">
                                <Path Stretch="Fill" Height="2" Width="14" Fill="{StaticResource WindowBackgroundBrush}" Data="F1 M 19,38L 57,38L 57,44L 19,44L 19,38 Z "/>
                            </Canvas>-->
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>

                    <Style x:Key="SliderStyle" TargetType="{x:Type Slider}">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type Slider}">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto" MinHeight="{TemplateBinding Slider.MinHeight}"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>

                            <Rectangle Margin="0, 0, 0, 0" Grid.Row="1" Height="1" Fill="{StaticResource DarkTextBrush}" />
                                        <!--<Path Margin="15,4,0,0" Grid.Row="1" Fill="{StaticResource WindowBackgroundBrush}" Data="F1 M 0,2.701660 L 0,4.179688 L 170.306641,4.179688 L 170.306641,2.701660 L 0,2.701660 Z"/>-->

                                        <Track Grid.Row="1" Name="PART_Track" Visibility="Visible">
                                            <Track.DecreaseRepeatButton>
                                                <RepeatButton Margin="-15, 0, 0, 0" Style="{StaticResource SliderDecrement}"
                                  Command="Slider.DecreaseLarge" />
                                            </Track.DecreaseRepeatButton>
                                            <Track.Thumb>
                                                <Thumb Margin="0,0,0,0" Style="{StaticResource ThumbBall}" />
                                            </Track.Thumb>
                                            <Track.IncreaseRepeatButton>
                                                <RepeatButton Margin="0, 0, -15, 0" Style="{StaticResource SliderIncrement}"
                                  Command="Slider.IncreaseLarge" />
                                            </Track.IncreaseRepeatButton>
                                        </Track>
                                    </Grid>

                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                <!--</ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>-->
        
    </UserControl.Resources>
    <Grid x:Name="grdEnter" >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="8" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <DockPanel Grid.ColumnSpan="2" Grid.Row="1" LastChildFill="True" x:Name="panelProgressBar">
            <!--<ProgressBar Height="8" Width="{Binding ElementName=panelProgressBar, Path=ActualWidth}"
                         Visibility="{Binding Project.Database.IsProcessing, Converter={StaticResource BooleanToVisibilityConverter}}" DockPanel.Dock="Top" HorizontalAlignment="Stretch" 
                         IsIndeterminate="{Binding Project.Database.IsProcessing}" />-->
        </DockPanel>
        
        <!-- #252525-->
        <!--<Grid x:Name="panelNavigation" Grid.Row="0" Grid.ColumnSpan="100" Background="{StaticResource MediumTextBrush}">-->
        <Grid x:Name="panelNavigation" Grid.Row="0" Grid.ColumnSpan="100" >
            <Grid.Background>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Color="#11FFFFFF" Offset="0" />
                    <GradientStop Color="#11FFFFFF" Offset="1" />
                </LinearGradientBrush>
            </Grid.Background>
            <Grid.ColumnDefinitions>
                <ColumnDefinition MinWidth="240" Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <StackPanel Grid.Column="0" Orientation="Horizontal" Margin="2, 4, 2, 4">
                <controls:CircleButton Command="{Binding SaveRecordAsyncCommand}" IsEnabled="{Binding Path=SaveRecordCommand.CanExecute}" PathData="F1 M 20.5833,20.5833L 55.4167,20.5833L 55.4167,55.4167L 45.9167,55.4167L 45.9167,44.3333L 30.0833,44.3333L 30.0833,55.4167L 20.5833,55.4167L 20.5833,20.5833 Z M 33.25,55.4167L 33.25,50.6667L 39.5833,50.6667L 39.5833,55.4167L 33.25,55.4167 Z M 26.9167,23.75L 26.9167,33.25L 49.0833,33.25L 49.0833,23.75L 26.9167,23.75 Z " />
                <!--<StackPanel Width="6" />
                <controls:CircleButton PathData="F1 M 19,50L 28,34L 63,34L 54,50L 19,50 Z M 19,28.0001L 35,28C 36,25 37.4999,24.0001 37.4999,24.0001L 48.75,24C 49.3023,24 50,24.6977 50,25.25L 50,28L 53.9999,28.0001L 53.9999,32L 27,32L 19,46.4L 19,28.0001 Z" />-->
                <StackPanel Width="6" />
                <controls:CircleButton Command="{Binding TryUnloadFormCommand}" IsEnabled="{Binding Path=TryUnloadFormCommand.CanExecute}" PathData="F1 M 26.9166,22.1667L 37.9999,33.25L 49.0832,22.1668L 53.8332,26.9168L 42.7499,38L 53.8332,49.0834L 49.0833,53.8334L 37.9999,42.75L 26.9166,53.8334L 22.1666,49.0833L 33.25,38L 22.1667,26.9167L 26.9166,22.1667 Z" />
                <StackPanel Width="6" />
                <controls:CircleButton Click="PrintButton_Click" Command="{Binding TogglePrintPreviewCommand}" IsEnabled="{Binding Path=SaveRecordAsyncCommand.CanExecute}" PathData="F1 M 25,27L 25,17L 51,17L 51,27L 47,27L 47,21L 29,21L 29,27L 25,27 Z M 16,28L 60,28L 60,51L 52,51L 52,46L 55,46L 55,33L 21,33L 21,46L 24,46L 24,51L 16,51L 16,28 Z M 25,39L 28,39L 28,52L 35,52L 35,59L 48,59L 48,39L 51,39L 51,62L 33,62L 25,54L 25,39 Z M 46,55L 38,55L 38,52L 46,52L 46,55 Z M 46,49L 30,49L 30,46L 46,46L 46,49 Z M 46,43L 30,43L 30,40L 46,40L 46,43 Z" />
                
                <StackPanel Width="6" />
                <controls:CircleButton Command="{Binding ToggleSearchCommand}" PathData="F1 M 42.5,22C 49.4036,22 55,27.5964 55,34.5C 55,41.4036 49.4036,47 42.5,47C 40.1356,47 37.9245,46.3435 36,45.2426L 26.9749,54.2678C 25.8033,55.4393 23.9038,55.4393 22.7322,54.2678C 21.5607,53.0962 21.5607,51.1967 22.7322,50.0251L 31.7971,40.961C 30.6565,39.0755 30,36.8644 30,34.5C 30,27.5964 35.5964,22 42.5,22 Z M 42.5,26C 37.8056,26 34,29.8056 34,34.5C 34,39.1944 37.8056,43 42.5,43C 47.1944,43 51,39.1944 51,34.5C 51,29.8056 47.1944,26 42.5,26 Z" />

                <StackPanel Width="6" Visibility="{Binding SelectedForm.IsRelatedForm, Converter={StaticResource BooleanToVisibilityConverter}, FallbackValue=Collapsed}" />
                <controls:CircleButton
                    Command="{Binding ReturnToParentCommand}"
                    Visibility="{Binding SelectedForm.IsRelatedForm, Converter={StaticResource BooleanToVisibilityConverter}, FallbackValue=Collapsed}"
                    PathData="F1 M 57,42L 57,34L 32.25,34L 42.25,24L 31.75,24L 17.75,38L 31.75,52L 42.25,52L 32.25,42L 57,42 Z" />


                <StackPanel Width="6" Visibility="{Binding SelectedForm.IsRelatedForm, Converter={StaticResource BooleanToVisibilityConverter}, FallbackValue=Collapsed}" />
                <controls:CircleButton
                    Command="{Binding ReturnToTopMostParentCommand}"
                    Visibility="{Binding SelectedForm.IsRelatedForm, Converter={StaticResource BooleanToVisibilityConverter}, FallbackValue=Collapsed}"
                    PathData="F1 M 24.0033,56.0078L 24.0033,38.0053L 22.0031,40.0056L 19.0027,35.0049L 38.0053,20.0028L 45.0063,25.5299L 45.0063,21.753L 49.0068,21.0029L 49.0068,28.6882L 57.008,35.0049L 54.0075,40.0056L 52.0073,38.0053L 52.0073,56.0078L 24.0033,56.0078 Z M 38.0053,26.9204L 27.0038,36.005L 27.0038,53.0074L 33.0046,53.0074L 33.0046,42.006L 43.006,42.006L 43.006,53.0074L 49.0068,53.0074L 49.0068,36.005L 38.0053,26.9204 Z" />
            </StackPanel>

            <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top" Height="Auto" Margin="2, 4, 2, 4">
                <Button x:Name="btnFirst" Margin="8, 0, 8, 0" Command="{Binding Path=MoveToFirstRecordCommand}" Style="{StaticResource NavButtonStyle}" IsEnabled="{Binding Path=MoveToFirstRecordCommand.CanExecute}">
                    <Button.Content>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="1" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>

                            <Path Grid.Column="2" HorizontalAlignment="Center" Width="12" Height="12" Stretch="Fill" Fill="{Binding ElementName=btnFirst, Path=Foreground}" Data="F1 M 30.0833,22.1667L 50.6665,37.6043L 50.6665,38.7918L 30.0833,53.8333L 30.0833,22.1667 Z">
                                <Path.RenderTransform>
                                    <RotateTransform CenterX="6" CenterY="6" Angle="180" />
                                </Path.RenderTransform>
                            </Path>
                            <Rectangle Grid.Column="0" Height="12" Width="2" Fill="{Binding ElementName=btnFirst, Path=Foreground}"></Rectangle>

                        </Grid>
                    </Button.Content>
                </Button>

                <Button x:Name="btnPrev" Margin="8, 0, 8, 0" Command="{Binding Path=MoveToPreviousRecordCommand}" Style="{StaticResource NavButtonStyle}" IsEnabled="{Binding Path=MoveToPreviousRecordCommand.CanExecute}">
                    <Button.Content>
                        <Grid>
                            <Path HorizontalAlignment="Center" Width="12" Height="12" Stretch="Fill" Fill="{Binding ElementName=btnPrev, Path=Foreground}" Data="F1 M 30.0833,22.1667L 50.6665,37.6043L 50.6665,38.7918L 30.0833,53.8333L 30.0833,22.1667 Z">
                                <Path.RenderTransform>
                                    <RotateTransform CenterX="6" CenterY="6" Angle="180" />
                                </Path.RenderTransform>
                            </Path>
                        </Grid>
                    </Button.Content>
                </Button>

                <TextBox x:Name="tbox1" Margin="16, 0, 0, 0" MinWidth="38" VerticalAlignment="Center" Text="{Binding SelectedForm.RecordsView.CurrentPosition, Mode=OneWay, NotifyOnSourceUpdated=True, Converter={StaticResource PlusOneConverter}}"></TextBox>
                <TextBlock Margin="6" VerticalAlignment="Center" Text="of" Foreground="{StaticResource DarkTextBrush}" />
                <TextBlock Margin="0, 0, 16, 0" VerticalAlignment="Center" DataContext="{Binding SelectedForm.RecordsView}" Foreground="{StaticResource DarkTextBrush}" Text="{Binding Path=Count, Mode=OneWay, NotifyOnSourceUpdated=True}" />

                <Button x:Name="btnNext" Margin="8, 0, 8, 0" Command="{Binding Path=MoveToNextRecordCommand}" Style="{StaticResource NavButtonStyle}">
                    <Button.Content>
                        <Grid>
                            <Path HorizontalAlignment="Center" Width="12" Height="12" Stretch="Fill" Fill="{Binding ElementName=btnNext, Path=Foreground}" Data="F1 M 30.0833,22.1667L 50.6665,37.6043L 50.6665,38.7918L 30.0833,53.8333L 30.0833,22.1667 Z"/>
                            <!--<Path HorizontalAlignment="Center" Grid.Row="0" Margin="6, 2, 6, 2" Width="28" Height="28" Stretch="Fill" Fill="White" Data="F1 M 38,0.791664C 58.5496,0.791664 75.2083,17.4504 75.2083,38C 75.2083,58.5496 58.5496,75.2083 38,75.2083C 17.4504,75.2083 0.791662,58.5496 0.791662,38C 0.791662,17.4504 17.4504,0.791664 38,0.791664 Z M 38,5.54166C 20.0738,5.54166 5.54167,20.0738 5.54167,38C 5.54167,55.9262 20.0738,70.4583 38,70.4583C 55.9262,70.4583 70.4583,55.9262 70.4583,38C 70.4583,20.0738 55.9262,5.54166 38,5.54166 Z "/>-->

                            <!--<TextBlock Foreground="White" HorizontalAlignment="Center" Grid.Row="1" Margin="1" FontSize="8pt" Text="Next" />-->
                        </Grid>
                    </Button.Content>
                </Button>

                <Button x:Name="btnLast" Margin="8, 0, 8, 0" Command="{Binding Path=MoveToLastRecordCommand}" Style="{StaticResource NavButtonStyle}">
                    <Button.Content>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="1" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>

                            <Path HorizontalAlignment="Center" Width="12" Height="12" Stretch="Fill" Fill="{Binding ElementName=btnLast, Path=Foreground}" Data="F1 M 30.0833,22.1667L 50.6665,37.6043L 50.6665,38.7918L 30.0833,53.8333L 30.0833,22.1667 Z" />
                            <Rectangle Grid.Column="2" Height="12" Width="2" Fill="{Binding ElementName=btnLast, Path=Foreground}"></Rectangle>

                            <!--<TextBlock Foreground="White" HorizontalAlignment="Center" Grid.Row="1" Margin="1" FontSize="8pt" Text="First" />-->
                        </Grid>
                    </Button.Content>
                </Button>

                <controls:CircleButton Command="{Binding AddRecordCommand}" IsEnabled="{Binding Path=AddRecordCommand.CanExecute}" Margin="8, 0, 0, 0" PathData="F1 M 35,19L 41,19L 41,35L 57,35L 57,41L 41,41L 41,57L 35,57L 35,41L 19,41L 19,35L 35,35L 35,19 Z" />
                <StackPanel Width="6" />
                <controls:CircleButton Command="{Binding DeleteRecordCommand}" IsEnabled="{Binding Path=DeleteRecordCommand.CanExecute}" PathData="F1 M 25.3333,23.75L 50.6667,23.75C 51.5411,23.75 51.8541,27.3125 51.8541,27.3125L 24.1458,27.3125C 24.1458,27.3125 24.4589,23.75 25.3333,23.75 Z M 35.625,19.7917L 40.375,19.7917C 40.8122,19.7917 41.9583,20.9378 41.9583,21.375C 41.9583,21.8122 40.8122,22.9584 40.375,22.9584L 35.625,22.9584C 35.1878,22.9584 34.0416,21.8122 34.0416,21.375C 34.0416,20.9378 35.1878,19.7917 35.625,19.7917 Z M 27.7083,28.5L 48.2916,28.5C 49.1661,28.5 49.875,29.2089 49.875,30.0834L 48.2916,53.8334C 48.2916,54.7078 47.5828,55.4167 46.7083,55.4167L 29.2917,55.4167C 28.4172,55.4167 27.7083,54.7078 27.7083,53.8334L 26.125,30.0834C 26.125,29.2089 26.8339,28.5 27.7083,28.5 Z M 30.0833,31.6667L 30.4792,52.25L 33.25,52.25L 32.8542,31.6667L 30.0833,31.6667 Z M 36.4167,31.6667L 36.4167,52.25L 39.5833,52.25L 39.5833,31.6667L 36.4167,31.6667 Z M 43.1458,31.6667L 42.75,52.25L 45.5208,52.25L 45.9167,31.6667L 43.1458,31.6667 Z" />
            </StackPanel>
        </Grid>

        <ScrollViewer Grid.Row="2" Grid.Column="1" Visibility="Visible" >

            <controls:DataEntryPages ItemsSource="{Binding SelectedForm.PagesView}" IsEnabled="{Binding Project.Database.IsProcessing, Converter={StaticResource BooleanInverter}}" >
                <controls:DataEntryPages.LayoutTransform>
                        <ScaleTransform  
                              ScaleX="{Binding ElementName=sliderZoom, Path=Value}" 
                              ScaleY="{Binding ElementName=sliderZoom, Path=Value}" />
                </controls:DataEntryPages.LayoutTransform>
            </controls:DataEntryPages>

        </ScrollViewer>

        <!-- #1E4A96 -->
        <Grid Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Height="24" Background="#22FFFFFF">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            
            <StackPanel Orientation="Horizontal" Grid.Column="0">
                <TextBlock Visibility="{Binding Project.Database.IsProcessing, Converter={StaticResource BooleanToVisibilityConverter}}" Margin="4" Foreground="{StaticResource DarkTextBrush}" Text="{Binding CurrentStatusMessage}" />
                <StackPanel Width="32" />
                <Border Margin="3" BorderThickness="1" BorderBrush="{StaticResource DarkTextBrush}" Visibility="{Binding Project.Database.IsProcessing, Converter={StaticResource BooleanToVisibilityConverter}}">
                    <ProgressBar Margin="2" Background="Transparent" Foreground="{StaticResource DarkTextBrush}"  Width="120" HorizontalAlignment="Stretch" IsIndeterminate="False" Value="{Binding Project.Database.ProcessingProgress}" />
                </Border>
            </StackPanel>

            <StackPanel Orientation="Horizontal" Grid.Column="0">
                <TextBlock Visibility="{Binding CurrentField, Converter={StaticResource LengthToVisibilityConverter}}" Margin="4" Foreground="{StaticResource DarkTextBrush}" Text="{Binding CurrentField}" />
            </StackPanel>

            <StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Right">
                
                <TextBlock FontSize="8pt" Margin="0, 0, 25, 0" Foreground="{StaticResource DarkTextBrush}" HorizontalAlignment="Center" VerticalAlignment="Center"
                           Text="{Binding ElementName=sliderZoom, Path=Value, Converter={StaticResource SliderValueConverter}}"
                           ></TextBlock>
                
                <Slider IsSnapToTickEnabled="True" TickFrequency="0.05" Value="1" Minimum="0.5" Maximum="3" SmallChange="0.10" LargeChange="0.20" TickPlacement="BottomRight"
                        x:Name="sliderZoom"
                        SnapsToDevicePixels="True"
                        Margin="4, 2, 24, 4" VerticalAlignment="Center" Style="{StaticResource SliderStyle}" Width="100" Height="Auto"></Slider>
            </StackPanel>
        </Grid>
        
        <Grid Grid.Row="2" Grid.Column="4" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0, 20, 0, 0" MaxWidth="400" MaxHeight="90"
              Visibility="{Binding SelectedForm.RecordsView.CurrentItem.Errors.HasErrors, Converter={StaticResource BooleanToVisibilityConverter}, FallbackValue=Collapsed}">
            <Grid.Style>
                <Style TargetType="{x:Type Grid}">
                    <Style.Triggers>
                        <Trigger Property="Visibility" Value="Visible">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
                                            <SplineDoubleKeyFrame KeyTime="00:00:00.200" Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <!--<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="Margin" DecelerationRatio="1" BeginTime="00:00:00" Duration="00:00:0.3">
                                            <SplineThicknessKeyFrame KeyTime="00:00:00" Value="20,0,-20,0" />
                                            <SplineThicknessKeyFrame KeyTime="00:00:0.3" Value="0,0,0,0" />
                                        </ThicknessAnimationUsingKeyFrames>-->
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Grid.Style>
            <Border BorderBrush="Red" BorderThickness="2, 2, 0, 2" Background="#DC000C" Padding="10">
                <Button Command="{Binding ToggleErrorDisplayCommand}">
                    <Button.Style>
                        <Style TargetType="{x:Type Button}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type Button}">
                                        <ContentPresenter />
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </Button.Style>
                    <Button.Content>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <TextBlock Foreground="White" Grid.Column="1" TextWrapping="WrapWithOverflow">Errors are detected in this record. Please correct all errors before proceeding.</TextBlock>

                            <StackPanel Grid.Column="0" Margin="0, 0, 20, 0">
                                <Path Width="43.9488" Height="40.9682" Stretch="Fill" Fill="White" Data="F1 M 58.5832,55.4172L 17.4169,55.4171C 15.5619,53.5621 15.5619,50.5546 17.4168,48.6996L 35.201,15.8402C 37.056,13.9852 40.0635,13.9852 41.9185,15.8402L 58.5832,48.6997C 60.4382,50.5546 60.4382,53.5622 58.5832,55.4172 Z M 34.0417,25.7292L 36.0208,41.9584L 39.9791,41.9583L 41.9583,25.7292L 34.0417,25.7292 Z M 38,44.3333C 36.2511,44.3333 34.8333,45.7511 34.8333,47.5C 34.8333,49.2489 36.2511,50.6667 38,50.6667C 39.7489,50.6667 41.1666,49.2489 41.1666,47.5C 41.1666,45.7511 39.7489,44.3333 38,44.3333 Z "/>
                            </StackPanel>

                        </Grid>
                    </Button.Content>
                </Button>
            </Border>
        </Grid>

        <content:RecordErrors Grid.RowSpan="100" Grid.ColumnSpan="100" Visibility="{Binding IsShowingErrorPanel, Converter={StaticResource BooleanToVisibilityConverter}, FallbackValue=Collapsed}" />

        <content:SaveChanges Grid.RowSpan="100" Grid.ColumnSpan="100" Visibility="{Binding IsShowingSave, Converter={StaticResource BooleanToVisibilityConverter}, FallbackValue=Collapsed}" />

        <pages:Search Grid.RowSpan="100" Grid.ColumnSpan="100" Visibility="{Binding IsShowingSearch, Converter={StaticResource BooleanToVisibilityConverter}, FallbackValue=Collapsed}" />
        

    </Grid>

</UserControl>
